package com.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.CustomerMessageDAO;
import com.dao.MessageFileDAO;
import com.entity.CustomerMessage;
import com.entity.MessageFile;

@Transactional
@Service
public class CustomerMessageService {
	@Autowired
	private CustomerMessageDAO customerMessageDAO;
	@Autowired
	private MessageFileDAO messageFileDAO;
	public boolean postMessage(CustomerMessage message){
		try{
			this.customerMessageDAO.insert(message);
			for(MessageFile file:message.getMessageFiles()){
				file.setCustomerMessage(message);
				this.messageFileDAO.insert(file);
			}
			return true;
		}catch(Exception e){
			return false;
		}
	}
}
